var e, t = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/regenerator")), o = require("../../../@babel/runtime/helpers/asyncToGenerator"), r = require("../../../utils/DPagination").default, a = require("../common"), n = a.getProjectNameLang, i = a.getLocation, s = getApp(), c = new r("stores"), l = s.getNetAddresss("plugin.store-projects.frontend.project.get-detail"), p = s.getNetAddresss("plugin.store-projects.frontend.project-order.get-detail"), d = s.getNetAddresss("plugin.store-projects.frontend.store.get-list-by-project-id"), u = null;

Page({
    data: {
        projectId: null,
        pageFrom: "details",
        stores: [],
        project: null,
        projectSimpleMode: !1,
        projectGoldenStyle: !1,
        projectNameLang: n()
    },
    onLoad: (e = o(t.default.mark(function e(o) {
        var r;
        return t.default.wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                if (o.project_id) {
                    e.next = 4;
                    break;
                }
                return wx.showToast({
                    title: n() + "不存在",
                    icon: "none"
                }), wx.navigateBack({
                    delta: 1
                }), e.abrupt("return");

              case 4:
                return c.bind(this), c.clean(), r = {
                    projectId: o.project_id
                }, o.from && (r.pageFrom = o.from), "details" !== o.from && "goods" !== o.from || (r.projectGoldenStyle = !0, 
                r.projectSimpleMode = !0), e.next = 11, i();

              case 11:
                u = e.sent, this.setData(r), this.getProject();

              case 14:
              case "end":
                return e.stop();
            }
        }, e, this);
    })), function(t) {
        return e.apply(this, arguments);
    }),
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {
        c.clean();
    },
    onPullDownRefresh: function() {
        c.clean(), this.getProject();
    },
    onReachBottom: function() {
        this.getProjectStore();
    },
    onShareAppMessage: function() {},
    getProject: function() {
        var e = this, t = s.qqMapTransBMap(parseFloat(u.point.lng), parseFloat(u.point.lat)), o = {
            lng: t.lng,
            lat: t.lat
        }, r = l;
        this.data.projectSimpleMode ? o.project_id = this.data.projectId : (r = p, o.id = this.data.projectId), 
        s._getNetWork({
            url: r,
            data: o,
            success: function(t) {
                var o = t.data.data, r = t.result, a = t.msg;
                0 != r ? (e.data.projectSimpleMode ? e.setData({
                    project: o.project
                }) : e.setData({
                    project: o
                }), e.getProjectStore()) : wx.showToast({
                    title: a,
                    icon: "none"
                });
            }
        });
    },
    getProjectStore: function() {
        if (!c.loading && !c.finished) {
            c.loading = !0;
            var e = s.qqMapTransBMap(parseFloat(u.point.lng), parseFloat(u.point.lat));
            s._getNetWork({
                url: d,
                data: {
                    project_id: this.data.project.project_id || this.data.project.id,
                    lng: e.lng,
                    lat: e.lat,
                    page: c.loadPage
                },
                success: function(e) {
                    var t = e.data.data, o = e.result, r = e.msg;
                    c.loading = !1, 0 != o ? ((t.current_page == t.last_page || t.data.length < t.per_page) && (c.finished = !0), 
                    c.push(t.data), wx.stopPullDownRefresh()) : wx.showToast({
                        title: r,
                        icon: "none"
                    });
                }
            });
        }
    }
});